package cn.openea.perpartner.meily.web.convert;

import cn.hutool.core.util.StrUtil;
import cn.openea.perpartner.meily.web.entity.dto.AttrData;
import cn.openea.perpartner.meily.web.entity.dto.AttrDataDto;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * @author Weird077
 * @description TODO
 * @date 2023-04-23 11:55
 */
@Mapper
public interface AttrDataConvert {
    AttrDataConvert INSTANCE = Mappers.getMapper(AttrDataConvert.class);
    @Mappings({@Mapping(source = "id", target = "id"),
            @Mapping(source = "title", target = "title"),
            @Mapping(source = "value", target = "value"),
            @Mapping(source = "type", target = "type"),
            @Mapping(source = "options", target = "options")})
    AttrDataDto toDto(AttrData data);


    default List<String> str2List(String src){
        return StrUtil.split(src, ',',  true, true);
    }
}
